package com.osi.mes.qm.services;

import java.util.Vector;

import pnuts.lang.Context;

import com.datasweep.compatibility.client.ATRow;
import com.datasweep.compatibility.client.ATRowFilter;
import com.datasweep.compatibility.client.DatasweepException;
import com.datasweep.compatibility.client.DsList;
import com.datasweep.compatibility.pnuts.Functions;
import com.datasweep.compatibility.ui.Time;
import com.osi.mes.utils.StringUtils;

public class QmServices extends QmEquService {

	public QmServices(Functions functions) {
		super(functions);
	}

	public QmServices(Context context) {
		super(context);
	}

	public Vector<String> getCollectionFromList(String listName) {
		Vector<String> resVector = new Vector<String>();
		DsList list = getFunctions().getList(listName);
		if (list == null)
			return resVector;
		for (int i = 0; i < list.getItems().size(); i++) {
			Object item = list.getItem(i);
			if (item != null)
				resVector.add(item.toString());
		}

		return resVector;
	}
	
	/**
	 * 查询客户投诉记录
	 */
	public Vector<ATRow> getCustomerCompliants(Time startTime,Time endTime,String cusName)throws DatasweepException
	{
		String atDef = AT_CUSTOMER_COMPLIANTS;
		ATRowFilter atRowFilter = getFunctions().createATRowFilter(atDef);
		if(startTime!=null)
		{
			atRowFilter.forColumnNameGreaterThanOrEqualTo(AT_CUSTOMER_COMPLIANTS_RECEIVE_COMP_TIME, getDayStart(startTime));
		}
		
		if(endTime!=null)
		{
			atRowFilter.forColumnNameLessThan(AT_CUSTOMER_COMPLIANTS_RECEIVE_COMP_TIME, getDayEnd(endTime));
		}
		
		if(StringUtils.isNotNull(cusName))
		{
			atRowFilter.forColumnNameContaining(AT_CUSTOMER_COMPLIANTS_CUSTOMER, cusName);
		}
		
		return super.getATRows(atRowFilter);
	}

}
